<template>
  <div>
    <el-table
      :data="arr"
      style="width: 100%; margin-bottom: 20px"
      row-key="id"
      border
      default-expand-all
      :tree-props="{ children: 'children' }"
    >
      <el-table-column prop="id" label="菜单编号" sortable width="180">
        <!-- <template slot-scope="scope">
            <span>{{scope.row.id}}</span>
        </template> -->
      </el-table-column>
      <el-table-column prop="title" label="菜单名称" sortable width="180">
        <!-- <template slot-scope="scope">
            <span>{{scope.row.title}}</span>
        </template> -->
      </el-table-column>
      <el-table-column  label="菜单图标"> 
        <template slot-scope="scope">
          <i :class="scope.row.icon"></i>
        </template></el-table-column>
      <el-table-column prop="url"  label="菜单地址" width="180"> </el-table-column>
      <el-table-column label="状态">
        <template slot-scope="scope">
          <el-button type="primary" v-if="scope.row.status == 1"  
            >启用</el-button
          >
          <el-button type="primary" v-else 
            >禁用</el-button
          >
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="primary" 
             @click="willUpdate(scope.row.id)">编辑</el-button
          >
          <el-button type="danger" 
          @click="del(scope.row.id)"
           >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { reqmenudelete } from '../../../http/api';
export default {
  data() {
    return {
      
    };
  },
  props:['arr','info'],
  methods: {
    willUpdate(id){
        console.log(id);
        this.$emit('willUpdate',id)
    },
    del(id){
        reqmenudelete({id}).then(res => {
            this.info.isshow = false;
            alert(res.data.msg)
            this.$emit('init')
        })
        
    }
  },
};
</script>

<style scoped>
/* .el-button {
  margin: 20px;
} */
.el-table{
    max-height: 500px;
}
.el-table-column {
  height: 60px;
  width: 100px;
}
</style>